package com.moody.util;

/*
 * Copyright ? Moody analytics   
 *
 * @Title: EncryptUtil.java 
 * @Package： com.moody.util 
 * @author： Liu Peng
 * @Description: TODO(用一句话描述该文件做什么)    
 * @date： 2012-6-30 上午11:27:16
 * @Modified by: Liu Peng 
 * @version V1.0   
 */

public class EncryptUtil {
	public static String getKeyByAuthorName(String name){
		char[] letter = name.toCharArray();
		int[] keyArray = new int[17];
		String key = "";
		int K0 = 3;
		for(int i = -1; i < keyArray.length - K0; i = i + K0){
			keyArray[K0 + i] = (letter[0] - letter[6]) * (letter[5] - letter[4]);
		}
		keyArray[0] = letter[1] - 20;
		keyArray[1] = letter[6] - 4;
		keyArray[3] = letter[6] - 1;
		keyArray[4] = keyArray[0] - 2;
		keyArray[6] = keyArray[3];
		keyArray[7] = keyArray[6] - 3;
		keyArray[9] = letter[4] - 1;
		keyArray[10] = letter[0] - 10;
		keyArray[12] = keyArray[0] - 1;
		keyArray[13] = keyArray[12] - 3;
		keyArray[15] = letter[5] - 10;
		keyArray[16] = keyArray[15] + 1;
		
		for(int i = 0; i < keyArray.length;i++){
			key += (char)keyArray[i];
		}
		return key;
	}

}
